'use strict';
const path = require('path');
const cwd = process.cwd();

const buildConf = require('../entry/entryConf.js');
// 工作空间根目录
const mainRootPath = path.join(cwd, `./${buildConf.repertoryPath}`);
const cProcess = require("child_process");
process.chdir(mainRootPath);
console.log(path.join(cwd, `./ctools.conf/unit/unitConf.js`));
// cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
const out = cProcess.exec(`cross-env BABEL_ENV=test karma start ${path.join(cwd, `./ctools.conf/unit/unitConf.js`)} --single-run`, {
  maxBuffer: 2000*1024,
  encoding: 'utf-8'
},e => {
  if (e) console.log(e);
});
out.stdout.on('data', (data) => {
  console.log(`stdout: ${data}`);
});

out.stderr.on('data', (data) => {
  console.log(`stderr: ${data}`);
});

out.on('close', (code) => {
  console.log(`子进程退出码：${code}`);
});
